package com.hjb.toolbardemo.fragment;

import android.content.Intent;
import android.util.Log;
import android.view.View;
import android.widget.LinearLayout;

import com.hjb.toolbardemo.R;
import com.hjb.toolbardemo.activity.ContainerActivity;
import com.hjb.toolbardemo.base.AppBaseFragment;
import com.hjb.toolbardemo.bean.MyData;
import com.hjb.toolbardemo.api.AppResponse;
import com.hjb.toolbardemo.utils.OkHttpUtils;
import com.okhttpfinal.MyBaseHttpRequestCallback;

import java.util.List;

import butterknife.ButterKnife;
import butterknife.InjectView;
import butterknife.OnClick;

/**
 * 作者 : hjb
 * 时间 : 2016/4/25.
 */
public class OneFragment extends AppBaseFragment {
    @InjectView(R.id.aa)
    LinearLayout mAa;

    @Override
    public View initRootView() {
        rootView = mInflater.inflate(R.layout.frag_one, null);
        ButterKnife.inject(this, rootView);
        return rootView;
    }

    @Override
    public void setViews() {
        setTitleTv("one");
    }

    @Override
    public void initData() {
        OkHttpUtils.listActivity(0, 10, new MyBaseHttpRequestCallback<AppResponse>() {
            @Override
            public void onRequestSuccess(AppResponse response) {
                List<MyData> data = response.getData();
            }

            @Override
            public void onRequestFailure(AppResponse message) {

            }
        });
    }

    @OnClick({R.id.button1, R.id.button2})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.button1:
                Intent intent = getActivity().getIntent();
                intent.putExtra("string", "setResult");
                getActivity().setResult(100, intent);
                getActivity().finish();
                break;
            case R.id.button2:
                new ContainerActivity().startActivityForResurt((ContainerActivity) getActivity(), TwoFragment.class, null, 13);
                break;
        }
    }

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        String string = data.getStringExtra("str");
        if (string != null)
            Log.i("string----", string);
    }

}
